Cover TOC Chap Prev Chap Prev Fig Next Fig Next Chap

Chapter 24: Adding Sound

../ch24/24fig05.gif
Figure 24.5

Two ambient sounds circling the origin.

24fig05.wrl
Click on the image to view the VRML scene.

#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
    children [
    # Origin marker
        Shape {
            appearance Appearance {
                material Material {
                    diffuseColor 0.0 0.0 0.0
                    emissiveColor 0.0 1.0 1.0
                }
            }
            geometry Sphere { radius 0.5 }
        },
    # Sound emitter 1
        DEF Emitter1 Transform {
            translation 5.0 0.0 0.0
            center -5.0 0.0 0.0
            children [
                Sound {
                    source AudioClip {
                        url "willow1.wav"
                        loop TRUE
                    }
                    intensity 0.5
                    minFront 5.0
                    minBack  5.0
                    maxFront 10.0
                    maxBack  10.0
                },
                DEF SoundMarker Inline { url "sndmark.wrl" }
            ]
        },
        DEF Emitter1Clock TimeSensor {
            cycleInterval 15.0
            loop TRUE
        },
        DEF Emitter1Path OrientationInterpolator {
            key [ 0.0, 0.5, 1.0 ]
            keyValue [ 0.0 1.0 0.0 0.0, 0.0 1.0 0.0 3.14, 0.0 1.0 0.0 6.28 ]
        },
    # Sound emitter 2
        DEF Emitter2 Transform {
            translation -5.0 0.0 0.0
            center 5.0 0.0 0.0
            children [
                Sound {
                    source AudioClip {
                        url "drone1.wav"
                        loop TRUE
                    }
                    intensity 0.5
                    minFront 5.0
                    minBack  5.0
                    maxFront 10.0
                    maxBack  10.0
                },
                USE SoundMarker
            ]
        },
        DEF Emitter2Clock TimeSensor {
            cycleInterval 7.0
            loop TRUE
        },
        DEF Emitter2Path OrientationInterpolator {
            key [ 0.0, 0.5, 1.0 ]
            keyValue [ 0.0 1.0 0.0 0.0, 0.0 1.0 0.0 3.14, 0.0 1.0 0.0 6.28 ]
        },
    ]
}
ROUTE Emitter1Clock.fraction_changed TO Emitter1Path.set_fraction
ROUTE Emitter2Clock.fraction_changed TO Emitter2Path.set_fraction
ROUTE Emitter1Path.value_changed     TO Emitter1.set_rotation
ROUTE Emitter2Path.value_changed     TO Emitter2.set_rotation